package org.kernely.security.persistence;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Details of the user (name, mail, activity...)
 */
@Entity
@Table(name="kernely_user_details",
		uniqueConstraints=@UniqueConstraint(columnNames="mail"))
public class UserDetails {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id_user_detail;
	
	private String name;
	
	private String firstname;
	
	private String activity;
	
	private String mail;
	
	private String image;
	
	private int civility;
	
	private String phone;
	
	private String address;
	
	private String skype;
	
	private String viadeo;
	
	private String linkedin;
	
	private String twitter;
	
	private String description;
	
	private String homepagebundle;
	
	private String homepageview;
	
	/**
	 * Constructor, with default values.
	 */
	public UserDetails(){
		this.id_user_detail = 0;
		this.name = "";
		this.firstname = "";
		this.activity = "";
		this.mail = "";
		this.image="";
		this.civility=0;
		this.phone="";
		this.address="";
		this.skype="";
		this.viadeo="";
		this.linkedin="";
		this.twitter="";
		this.description="";
		this.homepageview="";
		this.homepagebundle="";
		this.user = new User();
	}
	
	/**
	 * Retrieve the user's image
	 * @return the user's image
	 */
	public final String getImage() {
		return image;
	}

	
	/**
	 * Set the user's image
	 * @param image : the user's image
	 */
	public final void setImage(String image) {
		this.image = image;
	}

	@OneToOne
	@JoinColumn(name="fk_user_id")
	private User user;

	
	/**
	 * Get the user's civility
	 * @return the user's civility
	 */
	public final int getCivility() {
		return civility;
	}

	/**
	 * Set the user's civility
	 * @param civility : the user's civility
	 */
	public final void setCivility(int civility) {
		this.civility = civility;
	}
	
	/**
	 * Get the user's name
	 * @return the user's name
	 */
	public final String getName() {
		return name;
	}

	/**
	 * Set the User's name
	 * @param name : the user's name
	 */
	public final void setName(String name) {
		this.name = name;
	}

	/**
	 * Get the user's firstname
	 * @return : the user's firstname
	 */
	public final String getFirstname() {
		return firstname;
	}

	/**
	 * Set the user's firstname
	 * @param firstname : the user's firstname
	 */
	public final void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	/**
	 * Get the user's mail
	 * @return the user's mail
	 */
	public final String getMail() {
		return mail;
	}

	/**
	 * Set the user's mail
	 * @param mail : the user's mail
	 */
	public final void setMail(String mail) {
		this.mail = mail;
	}

	/**
	 * Get the userdetails' id
	 * @return : the userdetails' id
	 */
	public final int getId_user_detail() {
		return id_user_detail;
	}

	/**
	 * Set the userdetails' id
	 * @param idUserDetail : the userdetails' id
	 */
	public final void setId_user_detail(int idUserDetail) {
		id_user_detail = idUserDetail;
	}

	/**
	 * Get the User associated to this userDetails
	 * @return : the User associated
	 */
	public final User getUser() {
		return user;
	}

	/**
	 * Set the User associated to this Userdetails
	 * @param user : the User associated
	 */
	public final void setUser(User user) {
		this.user = user;
	}
	

	/**
	 * Gets the phone number
	 * @return the phone number
	 */
	public final String getPhone() {
		return phone;
	}


	/**
	 * Sets the phone
	 * @param phone the phone to set
	 */
	public final void setPhone(String phone) {
		this.phone = phone;
	}


	/**
	 * Gets the address
	 * @return the address
	 */
	public final String getAddress() {
		return address;
	}


	/**
	 * Sets the address
	 * @param address the address to set
	 */
	public final void setAddress(String address) {
		this.address = address;
	}


	/**
	 * Gets the skype
	 * @return the skype
	 */
	public final String getSkype() {
		return skype;
	}


	/**
	 * Sets the skype
	 * @param skype the skype to set
	 */
	public final void setSkype(String skype) {
		this.skype = skype;
	}


	/**
	 * Gets the viadeo
	 * @return the viadeo
	 */
	public final String getViadeo() {
		return viadeo;
	}


	/**
	 * Sets the viadeo
	 * @param viadeo the viadeo to set
	 */
	public final void setViadeo(String viadeo) {
		this.viadeo = viadeo;
	}


	/**
	 * Gets the linkedin
	 * @return the linkedin
	 */
	public final String getLinkedin() {
		return linkedin;
	}


	/**
	 * Sets the linkedin
	 * @param linkedin the linkedin to set
	 */
	public final void setLinkedin(String linkedin) {
		this.linkedin = linkedin;
	}


	/**
	 * Gets the twitter
	 * @return the twitter
	 */
	public final String getTwitter() {
		return twitter;
	}


	/**
	 * Sets the twitter
	 * @param twitter the twitter to set
	 */
	public final void setTwitter(String twitter) {
		this.twitter = twitter;
	}

	

	/**
	 * Gets the description
	 * @return the description
	 */
	public final String getDescription() {
		return description;
	}


	/**
	 * Sets the description
	 * @param description the description to set
	 */
	public final void setDescription(String description) {
		this.description = description;
	}


	
	
	/**
	 * Gets the activity
	 * @return the activity
	 */
	public String getActivity() {
		return activity;
	}


	/**
	 * Sets the activity
	 * @param activity the activity to set
	 */
	public void setActivity(String activity) {
		this.activity = activity;
	}
	
	


	/**
	 * Gets the homepagebundle
	 * @return the homepagebundle
	 */
	public String getHomepagebundle() {
		return homepagebundle;
	}

	/**
	 * Sets the homepagebundle
	 * @param homepagebundle the homepagebundle to set
	 */
	public void setHomepagebundle(String homepagebundle) {
		this.homepagebundle = homepagebundle;
	}

	/**
	 * Gets the homepageview
	 * @return the homepageview
	 */
	public String getHomepageview() {
		return homepageview;
	}

	/**
	 * Sets the homepageview
	 * @param homepageview the homepageview to set
	 */
	public void setHomepageview(String homepageview) {
		this.homepageview = homepageview;
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_user_detail;
		return result;
	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		UserDetails other = (UserDetails) obj;
		if (id_user_detail != other.id_user_detail) {
			return false;
		}
		return true;
	}



}
